#ifndef INTERVAL_H
#define INTERVAL_H
#include <limits>

class Interval {
  public:
    double min, max;


    Interval() : min(+std::numeric_limits<double>::infinity()), max(-std::numeric_limits<double>::infinity()) {} // Default interval is empty

    Interval(double min, double max) : min(min), max(max) {}

    Interval(const Interval&, const Interval&);

    Interval expand(double delta)const;

    double size() const {
        return max - min;
    }

    bool contains(double x) const {
        return min <= x && x <= max;
    }

    bool surrounds(double x) const {
        return min < x && x < max;
    }


    double clamp(double x)const;

    static const Interval empty, universe;
};

Interval operator+(const Interval& ival, double displacement);
Interval operator+(double displacement, const Interval& ival);

#endif